package com.kelvin.paopao.module.main.date.publish.editlocation;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.widget.Toolbar;
import android.text.TextUtils;
import android.view.MenuItem;
import android.widget.EditText;

import com.kelvin.kelvinlib.utils.ToastUtil;
import com.kelvin.paopao.R;
import com.kelvin.paopao.module.base.BaseActivity;
import com.kelvin.paopao.widgets.CustomToolbar;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by Administrator on 2017/6/20.
 */

public class EditLocationActivity extends BaseActivity {
    @BindView(R.id.custom_toolbar)
    CustomToolbar customToolbar;
    @BindView(R.id.et)
    EditText et;

    @Override
    protected int attachLayoutRes() {
        return R.layout.activity_edit_location_publish;
    }

    @Override
    protected void initInjector() {

    }

    @Override
    protected void initViews() {
        customToolbar.showBackIcon(this);
        customToolbar.inflateMenu(R.menu.menu_person_detail_confirm);
        customToolbar.setMenuOnClick(new Toolbar.OnMenuItemClickListener() {
            @Override
            public boolean onMenuItemClick(MenuItem item) {
                String result=et.getText().toString().trim();
                if(TextUtils.isEmpty(result)){
                    ToastUtil.showToast(EditLocationActivity.this,"地点不能为空");
                    return true;
                }
                Intent intent=new Intent();
                intent.putExtra("data",result);
                setResult(Activity.RESULT_OK,intent);
                finish();
                return true;
            }
        });
    }

    @Override
    protected void updateViews(boolean isRefresh) {

    }

    public static void launch(Activity activity,int requestCode){
        Intent intent=new Intent(activity,EditLocationActivity.class);
        activity.startActivityForResult(intent,requestCode);
    }
}
